#ifndef gdstk_test_h
#define gdstk_test_h

#include <gtest/gtest.h>
#include <stdio.h>
#include <gdstk/gdstk.hpp>
#include <ostream>

// #include "utils/utils.h"

using namespace gdstk;

// void exportGds(Cell* cell) {
//   Library lib = {};
//   lib.init("library", 1e-6, 1e-9);
//   lib.cell_array.append(cell);

//   Map<Cell*> cell_map = {};
//   Map<RawCell*> rawcell_map = {};
//   cell->get_dependencies(false, cell_map);
//   cell->get_raw_dependencies(false, rawcell_map);
//   for (MapItem<Cell*>* item = cell_map.next(NULL); item != NULL; item = cell_map.next(item)) {
//     lib.cell_array.append(item->value);
//   }

//   std::ostringstream gds_file, oas_file;
//   gds_file << "./data/test/" << cell->name << ".gds";
//   oas_file << "./data/test/" << cell->name << ".oas";
//   lib.write_gds(gds_file.str().c_str(), 0, NULL);
//   lib.write_oas(oas_file.str().c_str(), 0, 6, OASIS_CONFIG_DETECT_ALL);
// }

// TEST(GdstkTest, BasicAssertion) {
//   Cell cell = {};
//   cell.name = copy_string("FIRST", NULL);

//   Polygon rect = rectangle(Vec2{0, 0}, Vec2{2, 1}, make_tag(0, 0));
//   cell.polygon_array.append(&rect);

//   exportGds(&cell);
//   EXPECT_EQ(1, 1);
// }

TEST(GdstkReadGdsTest, BasicAssertion) {
  // const char* file = "D:/bylz/projects/cpp-template/data/138bit_line12.gds";
  const char* file = "E:/users/xqf/cpp-template/data/138bit_line12.gds";
  ErrorCode error_code;
  Set<Tag> shape_tags = {};
  auto lib = read_gds(file, 1e-6, 1e-9, &shape_tags, &error_code);
  EXPECT_EQ(1, 1);
}

TEST(GdstkReadOasTest, BasicAssertion) {
  // const char *file = "E:/projects/cpp/cpp-template/data/test/FIRST.oas";
  // const char* file = "E:/projects/cpp/cpp-template/data/test.oas";
  // gdstk::ErrorCode err;
  // utils::readFile(file);
  // gdstk::Library lib = gdstk::read_oas(file, 1e-6, 1e-9, &err);
  EXPECT_EQ(1, 1);
}

int main(int argc, char* argv[]) {
  ::testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();

  Library lib = {};
  lib.init("library", 1e-6, 1e-9);

  // Cell cell = {};
  // cell.name = copy_string("FIRST", NULL);
  // lib.cell_array.append(&cell);

  // Polygon rect = rectangle(Vec2{0, 0}, Vec2{2, 1}, make_tag(0, 0));
  // cell.polygon_array.append(&rect);

  // lib.write_gds("first.gds", 0, NULL);
  // lib.write_oas("first.oas", 0, 6, OASIS_CONFIG_DETECT_ALL);
  // cell.write_svg("first.svg", 10, 6, NULL, NULL, "#222222", 5, true, NULL);

  // rect.clear();
  // cell.clear();
  // lib.clear();
  return 0;
}

#endif